<?php
/**
 *
 * 下载次数统计
 *
 * 如果想显示下载次数,即把下面ＪＳ调用放到文档模板适当位置
 * <script src="{dede:global name='cfg_phpurl'/}/disdls.php?aid={dede:field name='id'/}" language="javascript"></script>
 *
 * @version        $Id: disdls.php 1 20:43 2010年7月8日Z tianya $
 * @package        DedeCMS.Site
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__)."/../include/common.inc.php");
$aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;

//获得频道模型ID
if($aid > 0)
{
	$row = $dsql->GetOne("SELECT ch.addtable,arc.mid FROM `#@__arctiny` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='$aid' ");
    $maintable = empty($row['addtable'])? '' : $row['addtable'];

}



if($type == 'dows'){
	//echo $maintable;
	$row = $dsql->GetOne("SELECT dows FROM `#@__archives` WHERE id='$aid' ");
	if(empty($row['totals'])) $row['totals'] = 0;
	echo "document.write('{$row['dows']}');";
}else if($type == 'stows'){
	$row = $dsql->GetOne("SELECT stows FROM `{$maintable}` WHERE aid='$aid' ");
	echo "document.write('{$row['stows']}');";
}else if($type == 'mb'){	$row = $dsql->GetOne("SELECT count(*) as num FROM `#@__member_operation` WHERE product='mb' and arcid='$aid' ");	echo "document.write('{$row['num']}');";}
exit();